package com.asman.worker.rn

import com.asman.worker.multishow.MultiShowActivity
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.ReactContextBaseJavaModule
import com.facebook.react.bridge.ReactMethod
import com.facebook.react.bridge.ReadableArray
import java.util.*

/**
 * author : ybk
 * date   : 2019-07-29 19:47
 * desc   : 图片视频展示
 */
class NativeMultiShow(reactContext: ReactApplicationContext) :
    ReactContextBaseJavaModule(reactContext) {

    override fun getName(): String {
        return "NativeMultiShow"
    }

    override fun getConstants(): Map<String, Any>? {
        val constants = HashMap<String, Any>()
        return constants
    }

    /**
     * 展示图片和视频混合 查看
     * @param currentIndex 当前图片下标
     * @param files 图片视频{"url":"","title":""}数组
     */
    @ReactMethod
    fun show(currentIndex: Int, files: ReadableArray) {
//        showToast(files.toString())
        currentActivity?.let { MultiShowActivity.start(it, files.toString(), currentIndex) }
    }
}



